package com.example.mydianping.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.mydianping.pojo.Follow;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface FollowMapper extends BaseMapper<Follow> {
    //查询 a 是否 拥有粉丝 b
    @Select("select * from tb_follow where user_id = #{a} and follow_user_id = #{b}")
    Integer judgeFollow(@Param("a") Long a,@Param("b") Long b);
    //取关
    @Delete("delete from tb_follow where user_id = #{a} and follow_user_id = #{b}")
    void deleteFan(@Param("a") Long a,@Param("b") Long b);
    //拿到对应用户的所有粉丝
    @Select("select follow_user_id from tb_follow where user_id = #{id}")
    List<Long> getFans(@Param("id") Long id);
}
